<template>
  <Modal v-model="visable" @on-cancel="close" @on-ok="okHandler">
    <div v-if="visable">
      <Form :model="model">
        <FormItem label="球场类型：" props="type">
        <Select v-model="model.type" default-label="篮球场" style="width:300px">
            <Option v-for="item in typeList" :value="item" :key="item">{{ item }}</Option>
        </Select>
        </FormItem>
        <FormItem label="球场名称：" props="name">
          <Input style="width: 300px" v-model="model.name" maxlength="20" />
        </FormItem>
         <FormItem label="开放时间：" props="kfsj">
          <TimePicker v-model="model.kfsj" format="HH:mm" type="timerange" placement="bottom-end" style="width: 300px"></TimePicker>
        </FormItem>
        <FormItem label="是否收费：" props="mfsf">
          <Radio-group v-model="model.mfsf">
            <Radio label="免费"></Radio>
            <Radio label="收费"></Radio>
          </Radio-group>
          <Input v-if="model.mfsf=='收费'" v-model="model.sfbz" style="width: 180px" placeholder="收费标准" maxlength="10"/>
        </FormItem>
        <FormItem label="室外室内：" props="snsw">
          <Radio-group v-model="model.snsw">
            <Radio label="室外"></Radio>
            <Radio label="室内"></Radio>
          </Radio-group>
        </FormItem>
        <FormItem label="场地电话：" props="cgdh">
          <Input style="width: 300px" v-model="model.cgdh" maxlength="13"/>
        </FormItem>
        <FormItem label="球场地址：" props="dizhi">
          <Input style="width: 300px" v-model="model.dizhi" maxlength="200"/>
        </FormItem>
      </Form>
    </div>
  </Modal>
</template>
<script>
export default {
  data() {
    return {
      visable: false,
      model: {
      },
      typeList: ['篮球场','足球场','羽毛球场','网球场','乒乓球场'], //场地类型
    };
  },
  methods: {
    okHandler() {
      if(this.model.name == ""){
        this.$Message.info('大兄弟,给球场起个名吧~');
        this.$emit("on-cancel");
        return;
      }
      [this.model.kssj,this.model.jssj] = this.model.kfsj;
      this.$axios.post("api/changdi/add", this.model).then(res => {
        this.$Message.success('添加成功,多谢球友!');
        this.$emit("on-ok", res);
      });
    },
    show(src) {
      this.model = {
        ...src
      };
      this.visable = true;
    },
    close() {
      this.$emit("on-cancel");
      this.visable = false;
    }
  }
};
</script>
<style lang="less" scoped>
.map_select {
  height: 400px;
}
.demo-upload-list {
  display: inline-block;
  width: 60px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  border: 1px solid transparent;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  position: relative;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
  margin-right: 4px;
}
.demo-upload-list img {
  width: 100%;
  height: 100%;
}
.demo-upload-list-cover {
  display: none;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
}
.demo-upload-list:hover .demo-upload-list-cover {
  display: block;
}
.demo-upload-list-cover i {
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  margin: 0 2px;
}
</style>